package icu.funkye.confine;

import icu.funkye.confine.spring.interceptor.ConfineInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Auto bean add for spring context if in springboot env.
 *
 * @author jianbin.chen
 */
@ConditionalOnWebApplication
@Configuration
public class HttpAutoConfiguration extends WebMvcConfigurerAdapter {

    @Autowired
    ConfineInterceptor confineInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(confineInterceptor).addPathPatterns("/**");
    }

}
